import BaseUtil from '@/BaseUtil';
import MathUtil from '@/MathUtil';
import SelectUtil from '@/SelectUtil';
import MovementCommon from 'code/Core/Common/MovementCommon';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/**
 * 跃击 - 淤泥怪
 **/
export default class MSK_JumpHit extends AbilityBase {
    static instance: MSK_JumpHit;
    constructor(id: string = 'Mnt1') {
        super(id);
        MSK_JumpHit.instance = this;
        this.init();
        se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
    }
    init() {}
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        let dis = MathUtil.distanceBetweenPoints(GetUnitX(source), GetUnitY(source), tarX, tarY);
        let ag = MathUtil.angleBetweenCoords(GetUnitX(source), GetUnitY(source), tarX, tarY);
        MovementCommon.hitFly({
            target: source,
            caster: source,
            distance: dis,
            angle: ag,
            time: 1,
            maxHeight: 350,
            onEnd: this.onEnd.bind(this),
        });
    }
    onEnd(p: HitFlyConfig) {
        DestroyEffect(AddSpecialEffect('Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl', p.curX, p.curY));
        let es = SelectUtil.getEnemyUnitsInRange(p.caster, 250);
        DamageSystemInstance.applyAoeMagicDamage(es, p.caster, 280, 'earth');
    }
    onSpellEffect() {
        let tar = GetSpellTargetUnit();
        let x = GetUnitX(tar);
        let y = GetUnitY(tar);
        let u = GetTriggerUnit();
        BaseUtil.runLater(1, () => {
            this.cast(x, y, u, tar);
        });
    }
}
